<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<%@ page import="java.util.List"%>

<%@page import="component.fulltextsearch.util.SearchConfigUtil"%>
<%@page import="component.fulltextsearch.util.Page"%>
<%@page import="component.fulltextsearch.constant.SearchConstant"%>
<%@page import="org.apache.lucene.document.Document"%>


<%@page import="component.list.util.ListConfigUtil"%><html>
<head>
<%
	String context = request.getContextPath();

	String indexDir = SearchConfigUtil.getIndexdir();

	Page curPage = (Page)request.getAttribute("page");
	List curPageData = curPage.getData();
	long totalCount = curPage.getTotalCount();
	long curStartNo = curPage.getStart() + 1;	
	long curEndNo = curPage.getStart() + curPageData.size();
	long curPageNo = curPage.getCurrentPageNo();
	long pageSize = curPage.getPageSize();
	
	String queryExpression = (String)request.getAttribute("queryExpression");
	if(queryExpression == null) queryExpression = "";
	
	//高级搜索的值
	String advanceQueryExpression = (String)request.getAttribute("advanceQueryExpression");
	String advanceQueryExpression2 = (String)request.getAttribute("advanceQueryExpression2");;//用于高级搜索页面显示的值
	String date = (String)request.getAttribute("date");
	String position = (String)request.getAttribute("position");
	if(advanceQueryExpression == null) advanceQueryExpression = "";
	if(advanceQueryExpression2 == null) advanceQueryExpression2 = "";
	if(date == null) date = "";
	if(position == null) position = "";
	
	String  action = context + SearchConfigUtil.getSearchUrl() + "?action=toList";
	
	String url = SearchConfigUtil.getBusUrl() + "?" + SearchConstant.NAME_BUSINESSSTRING + "=";
	
	String listPath = context + ListConfigUtil.getListPath();
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>

<link href="<%=(context + SearchConfigUtil.getSimpleCss())%>" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=listPath%>/js/ListUtil.js"></script>
<script type="text/javascript" src="<%=(context + SearchConfigUtil.getSearchPath())%>/js/SearchUtil.js"></script>
<script type="text/javascript" src="<%=context%>/common/js/ObjectFactory.js"></script>

<link type="text/css" rel="stylesheet" href="<%=listPath%>/css/toolbar.css" /><!-- 工具栏css -->
<link type="text/css" rel="stylesheet" href="<%=listPath%>/css/list.css" /><!-- 列表css -->

<script>
<!--

function setBackgroup(obj){
	obj.children[0].rows[0].cells(0).style.background='url("<%=listPath%>/image/tb-btn-sprite.gif") no-repeat 0 0px';
	obj.children[0].rows[0].cells(1).style.background='url("<%=listPath%>/image/tb-btn-sprite.gif") repeat-x 0 -42px';
	obj.children[0].rows[0].cells(2).style.background='url("<%=listPath%>/image/tb-btn-sprite.gif") no-repeat 0 -21px';
}

function unsetBackgroup(obj){
	obj.children[0].rows[0].cells(0).style.background='';
	obj.children[0].rows[0].cells(1).style.background='';
	obj.children[0].rows[0].cells(2).style.background='';
}

var listUtil = new ListUtil("<%=context%>","<%=SearchConfigUtil.getSearchUrl()%>","<%=listPath%>");
var searchUtil = new SearchUtil("<%=context%>","<%=SearchConfigUtil.getSearchUrl()%>");
var objFactory = new ObjectFactory();


function getAdvanceQueryExpression(){
	return "<%=advanceQueryExpression2%>";
}

function toAdvanceSearch(){
	var url = "<%=(context + SearchConfigUtil.getSearchPath())%>/advanceSearch.jsp?method=toList&advanceQueryExpression=" + getAdvanceQueryExpression() + "&date=<%=date%>&position=<%=position%>&pageSize=<%=pageSize%>";
	//url = url.replace("+","%20");// %2b
	url = encodeURI(url);
	objFactory.getWindow(url,800,300,'advanceSearch');
}

//-->
</script>
		
</head>

<body scroll="no">

<FORM action="<%=action%>" method="post">
	<INPUT type="hidden" name="pageSize" value="<%=pageSize %>" />
	<INPUT type="hidden" id="pageNo" name="pageNo" value="<%=curPageNo %>" />
	<INPUT type="hidden" id="queryExpression" name="queryExpression" value="<%=queryExpression %>" />
	
	<!-- 高级搜索的隐藏域 -->
	<input type="hidden" name="advanceQueryExpression" id="advanceQueryExpression" value="<%=advanceQueryExpression%>" />
	<input type="hidden" name="date" value="<%=date%>" />
	<input type="hidden" name="position" value="<%=position%>" >
	
	<table cellpadding="0" cellspacing="1" bgcolor="#BCBECB" class="list-content-table_3">
		<tr>
			<td valign="top" bgcolor="#FFFFFF">
			
				<!--工具栏开始-->
				<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
					<tr class="table_backgroud_5">
						<td height="37">
							<table border="0" width="100%" cellpadding="0" cellspacing="0">
								<tr>
									<!-- toolbar开始 -->
									<td nowarp='nowarp' width='100px'>
										<DIV class="x-toolbar x-small-editor">
											<TABLE cellSpacing="0">
												<TBODY>
													<TR>
														
														<!-- 按钮开始<td> -->
														<TD>
														<TABLE class="x-btn-wrap x-btn-text-icon badd x-btn"  style="WIDTH: auto" cellSpacing="0" cellPadding="0" border="0" 
														  onmouseover="setBackgroup(this);" onmouseout="unsetBackgroup(this);">
															<TBODY>
																<TR>
																	<TD class="x-btn-left" width="3px" height="21px">
																		<I>&nbsp;</I>
																	</TD>
																	<TD class="x-btn-center" style="padding-left:0; padding-right:0" >
																		<EM unselectable="on">
																			<BUTTON class="x-btn-text" onclick="listUtil.toAdd(800,600);" accesskey="a" >
																			 &nbsp;&nbsp; 新增(A) &nbsp;&nbsp; 
																			</BUTTON>
																		</EM>
																	</TD>
																	<TD class="x-btn-right" width="3px" height="21px"><I>&nbsp;</I></TD>
																</TR>
															</TBODY>
														</TABLE>
														</TD>
														<TD><SPAN class="ytb-sep" ></SPAN></TD><!-- 竖线 -->
														<!-- 按钮结束 -->
														
														<!-- 按钮开始<td> -->
														<TD>
														<TABLE class="x-btn-wrap x-btn-text-icon bedit x-btn"  style="WIDTH: auto" cellSpacing="0" cellPadding="0" border="0" 
														  onmouseover="setBackgroup(this);" onmouseout="unsetBackgroup(this);">
															<TBODY>
																<TR>
																	<TD class="x-btn-left" width="3px" height="21px">
																		<I>&nbsp;</I>
																	</TD>
																	<TD class="x-btn-center" style="padding-left:0; padding-right:0" >
																		<EM unselectable="on">
																			<BUTTON class="x-btn-text" onclick="listUtil.toEdit(800,600);" accesskey="e">
																			 &nbsp;&nbsp; 修改(E) &nbsp;&nbsp; 
																			</BUTTON>
																		</EM>
																	</TD>
																	<TD class="x-btn-right" width="3px" height="21px"><I>&nbsp;</I></TD>
																</TR>
															</TBODY>
														</TABLE>
														</TD>
														<TD><SPAN class="ytb-sep" ></SPAN></TD><!-- 竖线 -->
														<!-- 按钮结束 -->
														
														<!-- 按钮开始<td> -->
														<TD>
														<TABLE class="x-btn-wrap x-btn-text-icon bdel x-btn"  style="WIDTH: auto" cellSpacing="0" cellPadding="0" border="0" 
														  onmouseover="setBackgroup(this);" onmouseout="unsetBackgroup(this);">
															<TBODY>
																<TR>
																	<TD class="x-btn-left" width="3px" height="21px">
																		<I>&nbsp;</I>
																	</TD>
																	<TD class="x-btn-center" style="padding-left:0; padding-right:0" >
																		<EM unselectable="on">
																			<BUTTON class="x-btn-text" onclick="listUtil.doDelete();" accesskey="r">
																			 &nbsp;&nbsp; 删除(R) &nbsp;&nbsp; 
																			</BUTTON>
																		</EM>
																	</TD>
																	<TD class="x-btn-right" width="3px" height="21px"><I>&nbsp;</I></TD>
																</TR>
															</TBODY>
														</TABLE>
														</TD>
														<TD><SPAN class="ytb-sep" ></SPAN></TD><!-- 竖线 -->
														<!-- 按钮结束 -->
														
														<!-- 按钮开始<td> -->
														<TD>
														<TABLE class="x-btn-wrap x-btn-text-icon bdel x-btn"  style="WIDTH: auto" cellSpacing="0" cellPadding="0" border="0" 
														  onmouseover="setBackgroup(this);" onmouseout="unsetBackgroup(this);">
															<TBODY>
																<TR>
																	<TD class="x-btn-left" width="3px" height="21px">
																		<I>&nbsp;</I>
																	</TD>
																	<TD class="x-btn-center" style="padding-left:0; padding-right:0" >
																		<EM unselectable="on">
																			<BUTTON class="x-btn-text" onclick="listUtil.doDeleteAll();" >
																			 &nbsp;&nbsp; 删除所有 &nbsp;&nbsp; 
																			</BUTTON>
																		</EM>
																	</TD>
																	<TD class="x-btn-right" width="3px" height="21px"><I>&nbsp;</I></TD>
																</TR>
															</TBODY>
														</TABLE>
														</TD>
														<TD><SPAN class="ytb-sep" ></SPAN></TD><!-- 竖线 -->
														<!-- 按钮结束 -->

													</TR>
												</TBODY>
											</TABLE>
										</DIV>
									</td>
									<!-- toolbar结束 -->
									
									<!-- 搜索开始 -->
									<td nowarp='nowarp' align="right" valign="middle">	
										<INPUT type="text" onkeydown="if(event.keyCode==13){searchUtil.doSearch('query1');}" title="Gever 搜索" maxLength="2048" size="41" id="query1" name="query1" value="<%=queryExpression %>"  />
										<input type= "button" onclick="searchUtil.doSearch('query1')" class="button_img_1" value="搜索" id="query_button"/>
										<input type= "button" onclick="toAdvanceSearch()" class="button_img_1" value="高级搜索" id="advance_query_button"/>
									</td>
									<!-- 搜索结束 -->
								</tr>
							</table>
						</td>
					</tr>
				</table>
				<!-- 工具栏结束 -->

				<!-- 列表开始 -->
				<table width="100%" height="90%" border="0" cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td valign="top" height="100%">
							<div id='contentDiv'>
							<table width='100%' height='100%'>
								<!-- 数据区开始 -->
								<tr height='95%' valign='top'>
									<td>
									<div style='height: 100%; overflow: auto; border: 1px #7d7d7d solid;'>
									<table width='100%' border='0' cellspacing='0' cellpadding='0' style='vertical-align: top'>
										<thead>
											<tr class='list-head-tr'>
												<td class='list-head-td'><input type="checkbox" name="all" onclick="listUtil.selectAll(this)" /><td>
												<td class='list-head-td'>&nbsp;标题</td>
												<td class='list-head-td'>&nbsp;关键字</td>
												<td class='list-head-td'>&nbsp;摘要</td>
												<td class='list-head-td'>&nbsp;分类</td>
												<td class='list-head-td'>&nbsp;用户</td>
												<td class='list-head-td'>&nbsp;角色</td>
												<td class='list-head-td'>&nbsp;创建时间</td>
												<td class='list-head-td'>&nbsp;是否可删除</td>
											</tr>
										</thead>
										<tbody style='overflow: visible;'>
											<% for(int i =0; i < curPageData.size(); i ++) {
												Document document = (Document)curPageData.get(i);
												String name = document.getField(SearchConstant.NAME_NAME).stringValue();
												String keyValue = document.getField(SearchConstant.NAME_KEYVALUE).stringValue();
												String keyWord = document.getField(SearchConstant.NAME_KEYWORDS).stringValue();
												String createTime = document.getField(SearchConstant.NAME_CREATETIME).stringValue();
												String user = document.getField(SearchConstant.NAME_RIGHTUSERS).stringValue();
												String role = document.getField(SearchConstant.NAME_RIGHTROLES).stringValue();
												String summary = document.getField(SearchConstant.NAME_SUMMARY).stringValue();
												String type = document.getField(SearchConstant.NAME_TYPECODE).stringValue();
												String isDelete = document.getField(SearchConstant.NAME_ISDELETE).stringValue();
												String businessString = document.getField(SearchConstant.NAME_BUSINESSSTRING).stringValue();
											%> 
												<tr onMouseOver="listUtil.onTrMouseOver(this)" onMouseOut="listUtil.onTrMouseOut(this)" >
													<td class='list-body-td' width="30px" style='border-left: 0px'><input type="checkbox" name="fid" value="<%=keyValue%>" /><td>
													<td class='list-body-td' width="100px" onclick="listUtil.onTdClick(this)">&nbsp;&nbsp;<%=name%></td>
													<td class='list-body-td' width="150px" onclick="listUtil.onTdClick(this)">&nbsp;&nbsp;<%=keyWord%></td>
													<td class='list-body-td' width="600px" onclick="listUtil.onTdClick(this)">&nbsp;&nbsp;<%=summary%></td>
													<td class='list-body-td' width="70px" onclick="listUtil.onTdClick(this)">&nbsp;&nbsp;<%=type%></td>
													<td class='list-body-td' width="70px" onclick="listUtil.onTdClick(this)">&nbsp;&nbsp;<%=user%></td>
													<td class='list-body-td' width="70px" onclick="listUtil.onTdClick(this)">&nbsp;&nbsp;<%=role%></td>
													<td class='list-body-td' width="70px" onclick="listUtil.onTdClick(this)">&nbsp;&nbsp;<%=createTime%></td>
													<td class='list-body-td' width="70px" onclick="listUtil.onTdClick(this)">&nbsp;&nbsp;<%=isDelete%></td>
												</tr>
											<%} %>
										</tbody>
									</table>
									</div>
									</td>
								</tr>
								<!-- 数据区结束 -->
							</table>
						</td>
					</tr>
				</table>
				<!-- 列表结束 -->
				
				<!-- 分页开始 -->
				<DIV class="med" id="res" style="height:10%">
				<DIV class="e">
				<TABLE id="nav"	style="MARGIN: auto auto 1.4em; DIRECTION: ltr; BORDER-COLLAPSE: collapse; TEXT-ALIGN: center"	align="center">
					<TBODY>
						
						<TR vAlign="top">
							<TD>共<%=totalCount%>条记录，当前页有<%=curPageData.size()%>条记录</TD>
						<%			
							long linkSize = 10;
							long halfLinkSize = linkSize/2;			
							long startPageNO = (curPageNo > halfLinkSize) ? (curPageNo - halfLinkSize) : 1;
							long totalPageCount = curPage.getTotalPageCount();
							long endPageNO = (startPageNO + linkSize) < totalPageCount ? (startPageNO + linkSize) : totalPageCount;
							if (endPageNO == totalPageCount) {
								startPageNO =  (totalPageCount >  linkSize) ? totalPageCount -  linkSize : 1;
							}
							if (curPageNo > 1) {
								long toPage = curPageNo - 1;
								%>
								<TD class="b"><A onclick="searchUtil.toPage(<%=toPage %>)"  href="#">
									<SPAN class="csb ch" style="BACKGROUND-POSITION: -76px 0px; WIDTH: 66px; MARGIN-RIGHT: 34px"></SPAN><B>上一页</B>
								</A></TD>
								<%
							} else {
								%>
								<TD class="b"><SPAN class="csb"	style="BACKGROUND-POSITION: -26px 0px; WIDTH: 18px"></SPAN></TD>
								<%
							}
							for (long i = startPageNO; i <= endPageNO; i ++) {
								if (curPageNo != i) {					
									%>
									<TD><A href="#"	onclick="searchUtil.toPage(<%=i %>)">
										<SPAN class="csb ch" style="BACKGROUND-POSITION: -60px 0px; WIDTH: 16px"></SPAN><%=i %>
									</A></TD>
									<%
								} else {
									%>
									<TD class="cur"><SPAN class="csb" style="BACKGROUND-POSITION: -44px 0px; WIDTH: 16px"></SPAN><%=i %></TD>
									<%
								}
							}
							if (curPageNo < totalPageCount) {
								long toPage = curPageNo + 1;
								%>
								<TD class="b"><A onclick="searchUtil.toPage(<%=toPage %>)" href="#">
									<SPAN class="csb ch" style="BACKGROUND-POSITION: -76px 0px; WIDTH: 66px; MARGIN-RIGHT: 34px"></SPAN><B>下一页</B>
								</A></TD>
								<%
							} else {
								%>
								<TD class="b"><SPAN class="csb"	style="BACKGROUND-POSITION: -26px 0px; WIDTH: 18px"></SPAN></TD>
								<%
							}
						%>
						</TR>
					</TBODY>
				</TABLE>
				</DIV>
				</DIV>
				<!-- 分页结束 -->
				
			</td>
		</tr>
	</table>
	
</FORM>
</body>
</html>

